home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-20
/
nrd33.zip
/
STRUTIL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-12-01
|
2KB
|
118 lines
unit strutil;
{ {STRUTIL.PAS --- rev 1.0
Author: Tom Whiteside
11505 Oak View Dr
Austin, TX 78759
(512) 258-5924
Purpose: Various string utilities. These were
developed years ago for Apple Pascal and subsequently ported
to IBM Pascal then Turbo Pascal to migrate other code along.
Their main asset is their use by many lines of code and my
familiarity with them.
rev 1.0 }
interface
type lstring = string[255];
procedure int_to_str(num:integer; var strg:lstring);
procedure str_to_int(strg:lstring; var num:integer);
procedure rt_just(var t:lstring; len:integer);
procedure lf_just(var t:lstring; len:integer);
procedure date_format(var month,day,year:lstring);
implementation
uses intutil, dos;
{ convert int to string }
procedure int_to_str;
var tstrg:string[255];
s:string[1];
len,i:integer;
done:boolean;
begin
strg:='';
s:=' ';
i:=0;
done:=FALSE;
while (i < 255) and not done do
begin
s[1]:=chr((num mod 10) + ord('0'));
strg:=concat(s,strg);
num:=num div 10;
done:=num = 0;
i:=i + 1;
end;
end;
{ convert string to integer }
procedure str_to_int;
var i,t,len:integer;
ch:char;
begin
num:=0;
len:=length(strg);
if len > 4 then num:=32767
else
begin
for i:=1 to len do
begin
ch:=strg[i];
if ch in ['0'..'9'] then
begin
t:=ord(ch) - ord('0');
num:=num * 10 + t;
end;
end;
end;
end;
procedure rt_just;
begin
while length(t) < len do t:=concat(' ',t);
end;
procedure lf_just;
begin
while length(t) < len do t:=concat(t,' ');
end;
procedure date_format;
var tstrg:string[8];
dateval:string[255];
yr,mnth,dy,dyofweek:word;
begin
getdate(yr,mnth,dy,dyofweek);
case mnth of
1: month:='January';
2: month:='February';
3: month:='March';
4: month:='April';
5: month:='May';
6: month:='June';
7: month:='July';
8: month:='August';
9: month:='September';
10: month:='October';
11: month:='November';
12: month:='December';
else month:='???'
end;
int_to_str(dy,day);
int_to_str(yr,year);
end;
begin
end.